package com.ngkj.zmfptback.sys.service.read.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ngkj.zmfptback.sys.bean.RoleEntity;
import com.ngkj.zmfptback.sys.mapper.read.RoleAuthReadMapper;
import com.ngkj.zmfptback.sys.mapper.read.RoleReadMapper;
import com.ngkj.zmfptback.sys.service.read.RoleReadService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ChenHN
 * @since 2021/12/21 creation
 **/
@Service
@Transactional(readOnly = true)
public class RoleReadServiceImpl extends ServiceImpl<RoleReadMapper,RoleEntity> implements RoleReadService {

    @Resource
    private RoleReadMapper roleReadMapper;

    @Resource
    private RoleAuthReadMapper roleAuthReadMapper;

    @Override
    public List<RoleEntity> getAllRole(RoleEntity roleEntity) {
        return roleReadMapper.getAllRole(roleEntity);
    }

    @Override
    public IPage<RoleEntity> getPageRole(Page<RoleEntity> page, RoleEntity roleEntity) {
        return roleReadMapper.getPageRoles(roleEntity, page);
    }

    @Override
    public List<String> getMenuById(Long id) {
        return roleAuthReadMapper.getMenuById(id);
    }

    @Override
    public String getRoleIdByRoleCode(String roleCode) {
        return roleReadMapper.getRoleIdByRoleCode(roleCode);
    }

    @Override
    public List<String> getAuthsById(Long id,String type) {
        return roleAuthReadMapper.getRoleAuths(id,type);
    }



}
